package com.haste.service;

import com.haste.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;

/**
 * @ClassName:DeptClientHystrixService
 * @Description:服务降级
 * @Author:Haste
 * @Date:2021/2/3 11:25
 */
@Component
public class DeptClientHystrixService implements FallbackFactory {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept queryById(Long id) {
                return new Dept().setDeptId(id)
                        .setDeptName("查询的queryById服务已经关闭了，请访问其他服务")
                        .setDbSource("查询的queryById服务已经关闭了，请访问其他服务");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }


}
